@import 'mixins/overwrite';

@include b(pagination) {
  --#{$rd-prefix}pagination-size: 32px;

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 0;
  margin: 0;

  &:not(.#{$rd-prefix}pagination--mini) {
    .#{$rd-prefix}pagination__jump {
      @include polyfill-column-gap(4px);
    }

    @include polyfill-gap(8px, 8px);
  }

  @include when(change) {
    @include e(button) {
      @include m(number) {
        transition: none;
      }
    }
  }

  @include m(mini) {
    --#{$rd-prefix}pagination-size: 24px;

    @include polyfill-gap(4px, 2px);

    @include font-size(0.8rem);

    @include e(button) {
      &:not(.is-active) {
        border-color: transparent;
      }

      @include m(number) {
        padding: 0 4px;
      }
    }

    @include e(page-size) {
      height: 26px;
      padding: 0 6px;
    }

    @include e(jump) {
      @include polyfill-column-gap(2px);
    }

    @include e(jump-input) {
      width: 3em;
      height: 26px;
      padding: 0 6px;
    }
  }

  @include e(total) {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: top;
  }

  @include e(button) {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--#{$rd-prefix}pagination-size);
    height: var(--#{$rd-prefix}pagination-size);
    vertical-align: top;
    cursor: pointer;
    user-select: none;
    border-radius: var(--#{$rd-prefix}border-radius);
    outline: none;
    transition: border-color var(--#{$rd-prefix}animation-duration-base) linear, color var(--#{$rd-prefix}animation-duration-base) linear;

    &:hover,
    &:focus {
      color: var(--#{$rd-prefix}color-primary-lighter);
      border-color: var(--#{$rd-prefix}color-primary-lighter);
    }

    @include when(disabled) {
      color: var(--#{$rd-prefix}color-disabled);
      pointer-events: none;
    }

    @include when(active) {
      color: var(--#{$rd-prefix}color-primary);
      border-color: var(--#{$rd-prefix}color-primary);
    }

    @include m(number) {
      padding: 0 8px;
      transition: border-color var(--#{$rd-prefix}animation-duration-base) linear, color var(--#{$rd-prefix}animation-duration-base) linear,
        box-shadow var(--#{$rd-prefix}animation-duration-base) linear;

      &:focus-visible {
        box-shadow: 0 0 0 3px rgb(var(--#{$rd-prefix}color-primary-rgb) / var(--#{$rd-prefix}shadow-normal));
      }
    }

    @include m(border) {
      border: 1px solid var(--#{$rd-prefix}color-border);
    }

    @include m(jump5) {
      &:hover,
      &:focus {
        @include e(jump5-icon) {
          opacity: 1;
        }

        @include e(ellipsis) {
          opacity: 0;
        }
      }

      @include e(jump5-icon) {
        color: var(--#{$rd-prefix}color-primary);
        opacity: 0;
        transition: opacity var(--#{$rd-prefix}animation-duration-fast) linear;
      }
    }
  }

  @include e(ellipsis) {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--#{$rd-prefix}color-disabled);
    transition: opacity var(--#{$rd-prefix}animation-duration-fast) linear;
    transform: scale(1.5);
  }

  @include e(page-size) {
    @include overwrite-component(select) {
      width: auto;
      font-size: inherit;
    }
  }

  @include e(jump) {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: top;
  }

  @include e(jump-input) {
    @include overwrite-component(input) {
      width: 4.5em;
      font-size: inherit;
    }
  }
}
